package com.sig.message;

import java.util.HashMap;
import java.util.Map;

/**
 * @author sig
 * @since 2019/3/25
 */
public abstract class GeckoMessageManagerAdapter {
    protected final Map<Integer, Class<? extends GeckoMessage>> messageType2Classes = new HashMap<>();
    protected final Map<Class<? extends GeckoMessage>, Integer> messageClass2Types = new HashMap<>();

    protected abstract void init();

    public Class<? extends GeckoMessage> getClass(int type) {
        return messageType2Classes.get(type);
    }

    public int getType(Class<? extends GeckoMessage> clazz) {
        return messageClass2Types.get(clazz);
    }

    public void addType2Class(int type, Class<? extends GeckoMessage> clazz) {
        messageType2Classes.put(type, clazz);
    }

    public void addClass2Type(Class<? extends GeckoMessage> clazz, int type) {
        messageClass2Types.put(clazz, type);
    }
}
